package edu.scsu.csci.logging;

import edu.scsu.csci.util.ReflectionUtil;


/**
 * <p> Logging interface used by the framework. 
 * <p> Applications using the framework are free to 
 * 	   use any logger but the their logging class is expected
 * 	   to support this interface. 
 * 
 * @author Maqbool Khan
 * @since jdk 1.5
 */
public interface ILogger {
	
	/**
	 * Generic logging method.
	 * 
	 * @param logLevel
	 * @param logMessage
	 * @see
	 */
	void log(ELogLevel logLevel, String... logMessage);
	
	/**
	 * @param logMessage
	 */
	void info(String... logMessage);
	
	/**
	 * @param logMessage
	 */
	void debug(String... logMessage);
	
	/**
	 * @param logMessage
	 */
	void warn(String... logMessage);
	
	/**
	 * @param logMessage
	 */
	void error(String... logMessage);
	
	/**
	 * Logs the exception along with the error message.
	 * 
	 * @param e
	 * @param logMessage
	 */
	void error(Throwable e, String... logMessage);
	
	/**
	 * @param logMessage
	 */
	void fatal(String... logMessage);
	
	/**
	 * Sets the logLevel.
	 * 
	 * @param logLevel
	 */
	void setLogLevel(ELogLevel logLevel);
	
	/**
	 * Returns the current log level.
	 * 
	 * @return
	 */
	ELogLevel getLogLevel();
	
	
	/**
	 * <p> Log factory.
	 * <p> Creates an instnace of the logger specified for the framework.
	 * 
	 * @author Maqbool Khan
	 * @since jdk 1.5
	 * @see
	 */
	public static class LoggerFactory {
		
		
		/**
		 * Logger instance.
		 */
		private static ILogger logger;
		
		
		/**
		 * Creates a logger instance.
		 * 
		 * @param className
		 * @return
		 */
		public synchronized static ILogger create(String className)	{
			if(logger == null){
				logger = (ILogger) ReflectionUtil.instantiate(className);
			}
			return logger;
		}
		
		/**
		 * Returns the logger instace.
		 * 
		 * @return
		 */
		public static ILogger getLogger(){
			return logger;
		}
		
	}
}
